
<%@page import="com.wanmait.cookbook.vo.Pager"%>
<%@page import="com.wanmait.cookbook.vo.Cookbook"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<ul class="cook-list" id="count">
<%
	String path=request.getContextPath();
%>
						
						<!--菜谱的一个展示  -->
				<%
				String name=(String)request.getAttribute("name");
                List<Cookbook> burryCookbooks=(List<Cookbook>)request.getAttribute("cookbooks");
				if(burryCookbooks.size()==0){
					%>
					<span>没有相关菜谱</span>
					<%
				}else{
                List<Integer> burryCounts=(List<Integer>)request.getAttribute("cookbookCounts");
                for(int i=0;i<burryCookbooks.size();i++){
                %>

						<li class="clearfix"><a class="cook-img"
							href="<%=path %>/CookbookServlet?action=cookbookShow&id=<%=burryCookbooks.get(i).getId() %>"
							style="background-size: cover; position: relative;"
							title="<%=burryCookbooks.get(i).getInfo() %>" target="_blank"
							one-link-mark="yes"> <img
								src="<%=path%>/static/image/<%=burryCookbooks.get(i).getPic() %>"
								width="180" height="125"
								title="<%=burryCookbooks.get(i).getInfo() %>">
						</a>
							<div class="cook-info">
								<a class="cookname text-lips "
									href="<%=path %>/CookbookServlet?action=cookbookShow&id=<%=burryCookbooks.get(i).getId() %>"
									target="_blank" one-link-mark="yes"><%=burryCookbooks.get(i).getTitle() %></a>
								<!-- <p class="major">嫩豆腐,里脊肉,蒜,葱,油,老抽,盐,水,水淀粉 </p> -->
								 <span><%=burryCookbooks.get(i).getInfo() %></span>
								<div class="score">
								<!-- 收藏开始 -->
									<span class="shoucangzi">收藏</span> 
									<img width="20" class="shoucang"src="<%=path%>/img/shoucangkongxin.jpg">
								<!-- 收藏结束 -->
							</div>
								<div class="aut-num clearfix text-lips ">
									<a class="headicon"
										href="<%=path %>/PersonalServlet?action=init&id=<%=burryCookbooks.get(i).getUserinfo().getId() %>"
										target="_blank" one-link-mark="yes"> <img
										src="<%=path%>/static/image/<%=burryCookbooks.get(i).getUserinfo().getAvatar() %>"><%=burryCookbooks.get(i).getUserinfo().getName() %>
									</a> <a class="proicon" href="#"
										target="_blank" one-link-mark="yes"> 
									</a>
								</div>
							</div></li>
			<%} 
				}
			%>
						<!--菜谱展示结束  -->

					
						
					</ul>
					
					<!--分页数字开始  -->
					<div class="mt20">
						<div class="pages">
						
								<%
									Pager pager=(Pager)request.getAttribute("pager");
								int start = 1;
								int end = pager.getPageCount();
								if(pager.getPageCount()>5)
								{
									start = pager.getPageNo()-2<1?1:pager.getPageNo()-2;
									end = start+4;
									if(end>pager.getPageCount())
									{
										end = pager.getPageCount();
										start = end-4;
									}
								}
								%>
								<a href="javascript:void(0)" class="prevPager" one-link-mark="yes">上一页</a>
								<% for(int i=start;i<=end;i++){	
									if(i==pager.getPageNo()){
										%>
											<a href="javascript:void(0)" style="color:red" class="aliaon" one-link-mark="yes"><%=i %></a>
										<% 
									}else{
										%>
										<a href="javascript:void(0)" class="aliaon" one-link-mark="yes"><%=i %></a>
										<% 
									}} %>
								<a href="javascript:void(0)" class="nextPager" one-link-mark="yes">下一页</a>	
								<a href="javascript:void(0)" class="aliaon" one-link-mark="yes"><%=pager.getPageNo() %>/<%=pager.getPageCount() %></a>
									
										
								</div>
								</div>
								
							<!-- 分页结束 -->
							<!-- 上下页事件开始 -->
<script type="text/javascript">
$(function(){
	//上一页点击事件
	$(".prevPager").click(function(){
		var n=<%=pager.getPageNo()%>;
		$.ajax({
			url:"<%=path%>/FindBoxServlet",
			data:{action:"countCookbook",pageNo:n-1,name:"<%=name%>"},
			success:function(mes){
				$("#showList").html(mes);
			}
			
		});
	});
	//下一页点击事件
	$(".nextPager").click(function(){
		var n=<%=pager.getPageNo()%>;
		$.ajax({
			url:"<%=path%>/FindBoxServlet",
			data:{action:"countCookbook",pageNo:n+1,name:"<%=name%>"},
			success:function(mes){
				$("#showList").html(mes);
			}
			
		});
	});

})
</script>	
<!--上下页事件结束  -->	
				<!-- 收藏事件开始 -->
<script type="text/javascript">
	$(function(){
		$(".shoucang").click(function(){
			var shoucangsrc=$(this).attr("src");
			if(shoucangsrc=="<%=path%>/img/shoucangkongxin.jpg"){
				$(this).attr("src","<%=path%>/img/shoucangshixin.jpg");
				$(this).prev().html("已收藏")
			}
			else{
				$(this).attr("src","<%=path%>/img/shoucangkongxin.jpg");
					$(this).prev().html("收藏")
				}
			});
	});
</script>
<!-- 收藏事件结束 -->